#pragma once
#include <opencv2/opencv.hpp>
#include <string>
#include <vector>
#include <mutex>
#include <queue>
#include <thread>
#include <iostream>
#include <cctype>
#include <algorithm>
#include <map>

#include "camera_manager.h"
#include "activate_code/activate_code.h"
#include "common/modbus_api.h"
#include "common/video_tool.h"

namespace app {

class SmartBox
{
public:
	SmartBox(ConfigInfo* cfg_ifo, LogInfo* log_ifo);
	~SmartBox();

public:
	int get_rain_value();
	
  	int run();

private:
	void post_video_thread(); 
	void post_data_video_v2(std::multimap<int64, PostInfo>& cur_post_ifos, PostDataType pdt);
	void add_post_info(PostInfo pi, int post_type);
	void post_data(int64 end_time);
	

private:	
	friend class CameraManager;
	std::vector<CameraManager *> cam_mngs;

private:
	LogInfo *log_ifo;
	ConfigInfo* cfg_ifo;
	ActivateCode* act_code;
	ModbusAPI* mdb_api;

	std::atomic_int is_post;
	std::mutex post_mut;
	std::mutex post_video_mut;
	std::multimap<int64, PostInfo> post_ifos_text;
	std::multimap<int64, PostInfo> post_ifos_video;

	std::mutex rain_mut;
    int rain_value;
};

}   // namespace smartbox
